package com.xuya.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.xuya.dao.ProductDao;
import com.xuya.entity.Adminer;
import com.xuya.entity.Product;

public class NewServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	@Override
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		/*HttpSession session = req.getSession();
		Adminer adminer = (Adminer) session.getAttribute("user");
		if(adminer == null){
			resp.sendRedirect("index.jsp?code=10001");
			return;	
		}*/
		
		String id = req.getParameter("id");
		String name = req.getParameter("prodname");
		String price = req.getParameter("prodprice");
		Product p = new Product();
		p.setId(Integer.valueOf(id));
		p.setName(name);
		p.setPrice(Float.valueOf(price));
		ProductDao pdao = new ProductDao();
		pdao.editProduct(p);
		resp.sendRedirect("home.jspx");
		
	}

}
